<?php	
	$form = $_POST;
	$picture = new Picture();
	if ($picture_id) 	
	{
		
		$picture->select($picture_id);
		$picture->setdisplay_name($form["picture_name"]);
		$picture->update($picture_id);
		$msg = "Hình đã được sửa thành công";
	} 
	else 
	{
		$pic_id = check_and_upload_picture("picture", $form["picture_name"], $_FILES, array('loc_'));
		if ($pic_id) {		
			$location = new location();
			$location->select($location_id);
			$picture_ids = $location->getpictures();
			$picture_ids = json_decode($picture_ids, true);
			$picture_ids[] = $pic_id;
			$location->setpictures(json_encode($picture_ids));
			$location->update($location_id);
			$msg = "Hình đã được thêm thành công";
		}
			
		
	}
	
	admin_load($msg, "?act=pictures_location_list&location_id=".$location_id);
?>